//
//  NetworkLoadingViewController.swift
//  TestHHHHH
//
//  Created by 刘汤圆 on 2018/7/17.
//  Copyright © 2018年 刘汤圆. All rights reserved.
//

import UIKit
import SnapKit

open class NetworkLoadingViewController: UIViewController {

    var containView: UIView!
    var loadingImg : UIImageView!
    
    override open func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
        animate()
    }
    
    private func setupUI() {
        
        self.view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.4)
        
        containView = UIView()
        self.view.addSubview(containView)
        containView.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.8)
        containView.layer.masksToBounds = true
        containView.layer.cornerRadius = 6
        containView.snp.makeConstraints { (make) in
            make.width.equalTo(132)
            make.height.equalTo(116)
            make.center.equalTo(self.view)
        }
        
        loadingImg = UIImageView(image: UIImage(named: "loading-1"))
        containView.addSubview(loadingImg)
        loadingImg.snp.makeConstraints { (make) in
            make.center.equalTo(containView)
        }
    }
    
    private func animate() {
        var imgArr = [UIImage]()
        for i in 0..<2 {
            let imgName = "loading-\(i+1)"
            let img = UIImage(named: imgName)
            imgArr.append(img!)
        }
        loadingImg.animationImages = imgArr
        loadingImg.animationDuration = 1
        loadingImg.startAnimating()
    }


    deinit {
        print("NetworkLoading VC is dealloc")
    }


    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
